<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="jpath" value="${pageContext.request.contextPath }"/>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>新闻栏目</title>
		<%@include  file="../css.jsp"%>
	
	</head>

	<body>
	<div class="page-content">
		<div class="page-header">
			<h1>
				新闻栏目
			</h1>
		</div><!-- /.page-header -->
		<div class="row" style="margin:1rem auto 1.5rem auto; background-color: #eff3f8;">
			<div class="col-xs-12">
				<div class="row" style="margin: 0.5rem auto;">
					<div class="col-xs-12">
						<a href="#" onclick="Add()" class="btn btn-app btn-primary btn-sm">
							<i class="icon-edit bigger-200"></i>
							添加
						</a>
						<button onclick="deldlList()"  class="btn btn-app btn-danger btn-sm">
							<i class="icon-trash bigger-200"></i>
							删除
						</button>
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-xs-12">
				<!-- PAGE CONTENT BEGINS -->
				<div class="row">
					<div class="col-xs-12">
						<div class="table-responsive">
							<table id="sample-table-1" class="table table-striped table-bordered table-hover">
								<thead>
									<tr>
										<th class="center">
											<label>
												<input type="checkbox" class="ace" id="checkedAll" />
												<span class="lbl"></span>
											</label>
										</th>
										<th>栏目名称</th>
										<th>图片信息</th>
										<th>栏目封面</th>
										<th>创建时间</th>
										<th>Url链接</th>
										<th>操作</th>
									</tr>
								</thead>

								<tbody>
									
								</tbody>
							</table>
						</div><!-- /.table-responsive -->
					</div><!-- /span -->
				</div><!-- /row -->
			</div><!-- /.col -->
		</div><!-- /.row -->
	</div><!-- /.page-content -->
<%@include  file="../js.jsp"%>
<script type="text/javascript">
	function Update(nowId){
		location.href="${jpath}/NewsContr/ShowUpdate?NewsId="+nowId;
	}
	
	function delel(nowId){
		location.href="${jpath}/NewsContr/Delel?NewsId="+nowId;
	}
	
	function Add(){
		//location.href="${jpath}/Use/ShowUpdate";
		location.href="${jpath}/NewsContr/ShowAdd";
	}
	
	function deldlList(){
		var list=[];
		var checkList=$("input[name='checked']");
		for(var i=0;i<checkList.length;i++){
			if($(checkList[i]).is(":checked")){
				list[i]=$(checkList[i]).val();
			}
		}
		var idList=list.toString();
		location.href="${jpath}/NewsContr/Delel?idList="+idList;
	}
	

	function checkout(_this){
		var checkList=$("input[name='checked']");
		if($(_this).is(":checked")){
			var sum=0;
			for(var i=0;i<checkList.length;i++){
				if($(checkList[i]).is(":checked")==false){
					sum+=1;
				}
			}
			if(sum==0){
				$("#checkedAll").attr("checked",true);
			}else{
				$("#checkedAll").attr("checked",false);
			}
		}
	}
	

	
	
	
	$(function(){
		//loadTbl(1,4);
		var colM = 	[{
						name:"NewsId",
						cl:function(index,val){
							return "<label><input type='checkbox'  name='checked' onclick='checkout(this)'  class='ace' value='"+val+"' /><span class='lbl'></span></label>";
						}
					},{
						name:"ColumnName"
					},{
						name:"ImageInfo"
					},{
						name:"ColumnCover"
					},{
						name:"CreationTime"
					},{
						name:"UrlLink"
					},{
						name:"NewsId",
						cl:function(index,val){
							var data="<div class='btn-group'>";
							data+="<button class='btn btn-xs btn-info'  onclick='Update(\""+val+"\")' ><i class='icon-edit bigger-120'></i></button>";
							data+="<button class='btn btn-xs btn-danger' onclick='delel(\""+val+"\")' ><i class='icon-trash bigger-120'></i></button>";
							data+="</div>";
							return data;
						}
					}];
		var params={pageNum:1,pageSize:5};
		$("#sample-table-1").loadTbl(colM,params,"${jpath}/NewsContr/findByPage",true);
		
		$("#checkedAll").click(function(){
			var checkList=$("input[name='checked']");
	       	var sate = this.checked;
			for(var i=0;i<checkList.length;i++){
				checkList[i].checked = sate;
			}
		});
	});
</script>
</body>
</html>
